<%-- 
    Document   : addMovie
    Created on : May 3, 2011, 2:03:44 PM
    Author     : Kevin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="headero.html"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type"  content="text/html; charset=UTF-8">
        <script type="text/javascript">
            function validate(){
                with(document.form3){
                    if(title.value.length < 1){
                        alert("please input title");
                        title.focus();
                        return false;                        
                    }
                    if(director.value.length < 1){
                        alert("please input director");
                        director.focus();
                        return false;                        
                    }
                    if(duration.value.length < 1){
                        alert("please input duration");
                        duration.focus();
                        return false;                        
                    }
                    if(isNaN(duration.value)){
                        alert("please input number only");
                        duration.focus();
                        return false;                        
                    }
                    if(agerating.value.length < 1){
                        alert("please input agerating");
                        agerating.focus();
                        return false;                        
                    }if(synopsis.value.length < 1){
                        alert("please input synopsis");
                        synopsis.focus();
                        return false;                        
                    }if(synopsis.value.length > 100){
                        alert("synopsis must be less than 100 characters");
                        synopsis.focus();
                        return false;                        
                    } if(year.value.length < 1){
                        alert("please input release date");
                        year.focus();
                        return false;                        
                    }if(isNaN(year.value)){
                        alert("please input number");
                        year.focus();
                        return false;                        
                    }if(year.value.length != 4 ||year.value>2012||year.value<1900){
                        alert("year should be between 1900 and 2012");
                        year.focus();
                        return false;                        
                    } if(month.value.length < 1){
                        alert("please input release date");
                        month.focus();
                        return false;                        
                    } if(isNaN(month.value)){
                        alert("please input number");
                        month.focus();
                        return false;                        
                    } if(month.value>12||month.value<1){
                        alert("wrong month format");
                        month.focus();
                        return false;                        
                    } if(day.value.length < 1){
                        alert("please input release date");
                        day.focus();
                        return false;                        
                    } if(isNaN(day.value)){
                        alert("please input number");
                        day.focus();
                        return false;                        
                    } if(day.value < 1||day.value>31){
                        alert("wrong day formate");
                        day.focus();
                        return false;                        
                    } if(endyear.value.length < 1){
                        alert("please input end date");
                        endyear.focus();
                        return false;                        
                    } if(isNaN(endyear.value)){
                        alert("please input number");
                        endyear.focus();
                        return false;                        
                    } if(endyear.value.length != 4 ||endyear.value>2012||endyear.value<1900){
                        alert("year should be between 1900 and 2012");
                        endyear.focus();
                        return false;                        
                    } if(endmonth.value.length < 1){
                        alert("please input end date");
                        endmonth.focus();
                        return false;                        
                    } if(endmonth.value>12||endmonth.value<1){
                        alert("wrong month format");
                        endmonth.focus();
                        return false;                        
                    } if(endday.value.length < 1){
                        alert("please input end date");
                        endday.focus();
                        return false;                        
                    } if(isNaN(endday.value)){
                        alert("please input number");
                        endday.focus();
                        return false;                        
                    } if(endday.value < 1||endday.value>31){
                        alert("wrong day formate");
                        endday.focus();
                        return false;                        
                    } 
                }   
                return true;
            }
                
        
            
        </script>
        <title>Add Movie</title>
    </head>
    <body>
        <h1>Add a moive</h1>
        <form name="form3" onsubmit="return validate();" action="AddMovie" ENCTYPE="multipart/form-data" method="post">
            <table>
                <tr>
                    <td>Movie Title</td>
                    <td>            <input type="text" name="title"  size="20">
                    </td>
                </tr>
                <tr>
                    <td>Director</td>
                    <td>            <input type="text" name="director"  size="20">
                    </td>
                </tr>
                <tr>
                    <td>Duration:</td>
                    <td>            <input type="text" name="duration"  size="20">
                    </td>
                </tr>
                <tr>
                    <td>Age rating:</td>
                    <td>            <input type="text" name="agerating"  size="20">
                    </td>
                </tr>
                <tr>
                    <td>Youtube Video url:</td>
                    <td>            <input type="text" name="url"  size="20">
                    </td>
                </tr>
                <tr>
                    <td>Synopsis:</td>
                    <td>            <textarea name="synopsis" rows="10" cols="40" ></textarea>
                    </td>
                </tr>
                <tr>
                    <td>Genre:</td>
                    <td>            
                        <select name="genre" >
                            <option value="1">Drama</option>
                            <option value="2">Science Fiction</option>
                            <option value="3">Horror</option>
                            <option value="4">Action</option>
                            <option value="5">Comedy</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Release Date:</td>
                    <td>year:<input type="text" name="year" size="2"> month:<input type="text" name="month" size="2">day:<input type="text" name="day" size="2"></td>
                </tr>
                <tr>
                    <td>End Date:</td>
                    <td>year:<input type="text" name="endyear" size="2"> month:<input type="text" name="endmonth" size="2">day:<input type="text" name="endday" size="2"></td>
                </tr>
                <tr>
                    <td>Upload poster: </td>
                    <td><input type="file" name="file1"></td>
                </tr>
                             
                <tr>
                    <td><input type="submit" value="Add"></td><td></td>
            </table>
        </form> 
    </body>
</html>
<%@include file="footer.html"%>
